import { defineSchema } from 'easy'

const schema = defineSchema({
  // request needs to have a querystring with a `name` parameter
  query: {
    name: {
      type: 'string',
      maxLength: 10,
      pattern: val => /^[a-z]\w{4,15}$/i.test(val),
      desc: '用户名',
      message: {
        pattern: '用户名不合法(以字母开头，允许5-16字节，允许字母数字下划线)',
      },
    },
    password: {
      type: 'string',
      pattern: val => /^[a-z]\w{5,17}$/i.test(val),
      desc: '密码',
      message: {
        pattern: '密码不合法(以字母开头，长度在6~18之间，只能包含字母、数字和下划线)',
      },
    },
    sex: { type: 'string', desc: '性别' },
    age: { type: 'number', desc: '年龄' },
  },
  // params: {
  //   name: { type: 'string' },
  //   age: { type: 'number' },
  //   isMax: { type: 'boolean' },
  // },
})
export default schema
